Compiler Wrapping
This feature can be used with build systems that use an environment variable to specify the compiler to be used, for example:
The feature works by assigning the qacli command for adding a file and its dependencies to a Helix QAC project, to the required compiler variable. It applies to any build system that can alias the compilation command, for example a Make-based system:
In this situation, instead of your normal compiler receiving the arguments in the build, qacli
will receive them directly, and they will be placed after the --ignore-rest
switch. The qacli
command will parse the arguments, search for a source file path, Include paths and macro Definitions, and, if a source file is found, it will be added to the project along with the other data. As soon as this is done, qacli
will use the argument to the --compile_command
option and issue it to the system, compiling your files as normal.
The qacli project files --add
feature returns a non-zero value if it fails to add the file. This may not be desirable in all circumstances as a build will normally exit if a tool returns a non-zero value. To prevent the build from exiting on make-based systems, a dash can be added in front of the command:
make CXX='-qacli project files -P <directory> -z g++ --add --' / CC='-qacli project files -P <directory> -z gcc --add --'
--
is a shortcut for --ignore-rest.
-z <command>
is a shortcut for --compile-command <command>
.
The -z g++
part of the command tells Helix QAC to compile each file after extracting it together with its compile-dependent information. This is necessary for systems that build artefacts needed later in the build process. If your compile command contains spaces (for example, g++ -Wall)
or other characters that may confuse a shell, then place the compile command in a script or batch file and make it executable. For example, you could use a file named compiler_cpp.sh
to wrap the compile command as follows: #!/bin/bash
Given that a similar file for the C compiler could be created, the make command from the example above could now resemble the following:
The Compiler Wrapping method can be used in any build system that allows the substitution of the compile command.
As with Build Process Monitoring, ensure that you clean the project before building.